using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Microsoft.DesignerSupport;

namespace XMTAEditor
{
	public partial class ClassEditor : BaseEditor
	{
		public ClassEditor()
		{
			InitializeComponent();
		}

		private ClassType ct;

		public ClassType Class
		{
			get { return ct; }
			set { ct = value; Fill(); }
		}

		protected override void Fill()
		{
			description.Text = BindUtil.ToText(ct.Description);
			defEvent.Text = BindUtil.ToText(ct.DefaultEvent);
			defProp.Text = BindUtil.ToText(ct.DefaultProperty);
			checkBoxList1.Items[0].State = BindUtil.ToCheck(ct.DesignTimeVisible);
			checkBoxList1.Items[1].State = BindUtil.ToCheck(ct.DesktopCompatible);
			checkBoxList1.Items[2].State = BindUtil.ToCheck(ct.ImmutableObject);
			checkBoxList1.Items[3].State = BindUtil.ToCheck(ct.Supported);
			checkBoxList1.Items[4].State = BindUtil.ToCheck(ct.SuppressFiltering);
			checkBoxList1.Refresh();
		}

		public override void Save()
		{
			changed = false;
			ct.Description = BindUtil.ToVar(description.Text);
			ct.DefaultEvent = BindUtil.ToVar(defEvent.Text);
			ct.DefaultProperty = BindUtil.ToVar(defProp.Text);
			ct.DesignTimeVisible = BindUtil.FromCheck(checkBoxList1.Items[0].State);
			ct.DesktopCompatible = BindUtil.FromCheck(checkBoxList1.Items[1].State);
			ct.ImmutableObject = BindUtil.FromCheck(checkBoxList1.Items[2].State);
			ct.Supported = BindUtil.FromCheck(checkBoxList1.Items[3].State);
			ct.SuppressFiltering = BindUtil.FromCheck(checkBoxList1.Items[4].State);
		}

		private void ClassEditor_Load(object sender, EventArgs e)
		{

		}

		private void defEvent_TextChanged(object sender, EventArgs e)
		{
			changed = true;
		}
	}
}
